package com.app.designpatternslearn.structured.flyweightpattern.code

class FlyweightFactory {

    private val caches = HashMap<String, IFlyweight>()

    fun getFlyweight(key: String):IFlyweight? = if (caches.containsKey(key)) {
        caches[key]
    } else {
        val iFlyweight = ConcreteFlyweight(key)
        caches[key] = iFlyweight
        iFlyweight
    }

}